<?php 
// +----------------------------------------------------------------------
// | Etion [ http://www.etion.cn ]
// +----------------------------------------------------------------------
// | File: FcartAction.class.php
// +----------------------------------------------------------------------
// | Date: 2010
// +----------------------------------------------------------------------
// | Author: 李汝康 <37739419@qq.com>
// +----------------------------------------------------------------------
// | 文件描述: 维护购物车
// +----------------------------------------------------------------------

/**
 * @name购物车维护
 * @author netwom
 *
 */
class FcartAction extends FbaseAction {

	
	
	/**
	 * @name显示购物车
	 * 
	 */
	public function show() {
		$in = &$this->in;
		//$_SESSION[cart]="";
		$total="";
		foreach($_SESSION[cart] as $k){
			$total += $k['price'];
		}
		$seo['seotitle'] = L ('购物车订单') . C('SITE_TITLE_SEPARATOR') . L('会员中心') . C('SITE_TITLE_SEPARATOR') . C('SEOTITLE');
		$seo['seokeywords'] = C('SEOKEYWORDS');
		$seo['seodescription'] = C('SEODESCRIPTION');
	    $seo['url'] = C ('SITEURL') . 'user/home';
	    $this->assign('seo',$seo);
	    $this->assign('total',$total);
		$this->assign("left_cart",$_SESSION[cart]);
		$this->display('cart/cart.html');
	}
	public function add(){
		$in = &$this->in;
		$_content = D (Category);
		$where['catid']=$in['catid'];
		$m = $_content->where($where)->find();
		$cat_url=$m['url'];
		$in['url']=$cat_url.$in['url'];
		if($in['catid']==31){
			$_con = D (ContentJiudianPrice);
			$wher['id']=$in['id'];
			$n = $_con->where($wher)->find();
			$in['fangxing']=$n['fangxing'];
			$in['price']=$n['youhui'];
		}
		$_SESSION['cart'][$in['cid']]=$in;
		print_r($_SESSION['cart']);

	}
	
	public function ajaxnum() {
		$in = &$this->in;
		//$_SESSION[cart]="";
		$_SESSION['cart'][$in['cid']]['num']=$in['num'];
	}
	public function del(){
		$in = &$this->in;
		unset($_SESSION[cart][$in['cid']]);
		$this->show();
	}
//	public function upd(){
//		$in = &$this->in;
//		if($in['type']=="add"){
//			if($_SESSION[cart][$in['orderid']]['number'] < 999){
//				$_SESSION[cart][$in['orderid']]['number']=$_SESSION[cart][$in['orderid']]['number']+1;
//			}
//		}
//		if($in['type']=="minus"){
//			if($_SESSION[cart][$in['orderid']]['number'] > 1){
//				$_SESSION[cart][$in['orderid']]['number']=$_SESSION[cart][$in['orderid']]['number']-1;
//			}
//		}
//		$number=$_SESSION[cart][$in['orderid']]['number'];
//		$priceall=$_SESSION[cart][$in['orderid']]['number']*$_SESSION[cart][$in['orderid']]['price'];
//		$m=array($number,$priceall);
//		echo json_encode($m);
//	}
//	
//	
//	public function showall() {
//		$in = &$this->in;
//		
//		$time01=date( "M d",strtotime( "+1   day "));
//		$time02=date( "M d",strtotime( "+4   day "));
//		$this->assign("time01",$time01);
//		$this->assign("time02",$time02);
//		
//		foreach($_SESSION[cart] as $k){
//			$SubTotal+=$k['number']*$k['price'];
//		}
//		$Total=$SubTotal+10.00;
//		$this->assign("SubTotal",$SubTotal);
//		$this->assign("Total",$Total);
//		$this->assign("cartall",$_SESSION[cart]);
//		$this->display('cart/cartall.html');
//	}
//	
//	public function remove(){
//		$in = &$this->in;
//		
//		$time01=date( "M d",strtotime( "+1   day "));
//		$time02=date( "M d",strtotime( "+4   day "));
//		$this->assign("time01",$time01);
//		$this->assign("time02",$time02);
//		
//		unset($_SESSION[cart][$in['orderid']]);
//		foreach($_SESSION[cart] as $k){
//			$SubTotal+=$k['number']*$k['price'];
//		}
//		$Total=$SubTotal+10.00;	
//		$this->assign("SubTotal",$SubTotal);
//		$this->assign("Total",$Total);
//		$this->assign("cartall",$_SESSION[cart]);
//		$this->display('cart/cartall.html');
//	}
//	
//	public function update(){
//		$in = &$this->in;
//		
//		$time01=date( "M d",strtotime( "+1   day "));
//		$time02=date( "M d",strtotime( "+4   day "));
//		$this->assign("time01",$time01);
//		$this->assign("time02",$time02);
//		
//		if($in['type']=="add"){
//			if($_SESSION[cart][$in['orderid']]['number'] < 999){
//				$_SESSION[cart][$in['orderid']]['number']=$_SESSION[cart][$in['orderid']]['number']+1;
//			}
//		}
//		if($in['type']=="minus"){
//			if($_SESSION[cart][$in['orderid']]['number'] > 1){
//				$_SESSION[cart][$in['orderid']]['number']=$_SESSION[cart][$in['orderid']]['number']-1;
//			}
//		}
//		
//		foreach($_SESSION[cart] as $k){
//			$SubTotal+=$k['number']*$k['price'];
//		}
//		$Total=$SubTotal+10.00;	
//		$this->assign("SubTotal",$SubTotal);
//		$this->assign("Total",$Total);
//		$this->assign("cartall",$_SESSION[cart]);
//		$this->display('cart/cartall.html');
//		
//	}
	
}